|
1
|
|
|
/** |
|
2
|
|
|
* @license AngularJS v1.8.3 |
|
3
|
|
|
* (c) 2010-2020 Google LLC. http://angularjs.org |
|
4
|
|
|
* License: MIT |
|
5
|
|
|
*/ |
|
6
|
|
|
|
|
7
|
|
|
(function() {'use strict'; |
|
8
|
|
|
// NOTE: |
|
9
|
|
|
// These functions are copied here from `src/Angular.js`, because they are needed inside the |
|
10
|
|
|
// `angular-loader.js` closure and need to be available before the main `angular.js` script has |
|
11
|
|
|
// been loaded. |
|
12
|
|
|
function isFunction(value) {return typeof value === 'function';} |
|
13
|
|
|
function isDefined(value) {return typeof value !== 'undefined';} |
|
14
|
|
|
function isNumber(value) {return typeof value === 'number';} |
|
15
|
|
|
function isObject(value) {return value !== null && typeof value === 'object';} |
|
16
|
|
|
function isScope(obj) {return obj && obj.$evalAsync && obj.$watch;} |
|
17
|
|
|
function isUndefined(value) {return typeof value === 'undefined';} |
|
18
|
|
|
function isWindow(obj) {return obj && obj.window === obj;} |
|
19
|
|
|
function sliceArgs(args, startIndex) {return Array.prototype.slice.call(args, startIndex || 0);} |
|
20
|
|
|
function toJsonReplacer(key, value) { |
|
21
|
|
|
var val = value; |
|
22
|
|
|
|
|
23
|
|
|
if (typeof key === 'string' && key.charAt(0) === '$' && key.charAt(1) === '$') { |
|
24
|
|
|
val = undefined; |
|
25
|
|
|
} else if (isWindow(value)) { |
|
26
|
|
|
val = '$WINDOW'; |
|
27
|
|
|
} else if (value && window.document === value) { |
|
28
|
|
|
val = '$DOCUMENT'; |
|
29
|
|
|
} else if (isScope(value)) { |
|
30
|
|
|
val = '$SCOPE'; |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
return val; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
/* exported toDebugString */ |
|
37
|
|
|
|
|
38
|
|
|
function serializeObject(obj, maxDepth) { |
|
39
|
|
|
var seen = []; |
|
40
|
|
|
|
|
41
|
|
|
// There is no direct way to stringify object until reaching a specific depth |
|
42
|
|
|
// and a very deep object can cause a performance issue, so we copy the object |
|
43
|
|
|
// based on this specific depth and then stringify it. |
|
44
|
|
|
if (isValidObjectMaxDepth(maxDepth)) { |
|
45
|
|
|
// This file is also included in `angular-loader`, so `copy()` might not always be available in |
|
46
|
|
|
// the closure. Therefore, it is lazily retrieved as `angular.copy()` when needed. |
|
47
|
|
|
obj = angular.copy(obj, null, maxDepth); |
|
48
|
|
|
} |
|
49
|
|
|
return JSON.stringify(obj, function(key, val) { |
|
50
|
|
|
val = toJsonReplacer(key, val); |
|
51
|
|
|
if (isObject(val)) { |
|
52
|
|
|
|
|
53
|
|
|
if (seen.indexOf(val) >= 0) return '...'; |
|
54
|
|
|
|
|
55
|
|
|
seen.push(val); |
|
56
|
|
|
} |
|
57
|
|
|
return val; |
|
58
|
|
|
}); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
function toDebugString(obj, maxDepth) { |
|
62
|
|
|
if (typeof obj === 'function') { |
|
63
|
|
|
return obj.toString().replace(/ \{[\s\S]*$/, ''); |
|
64
|
|
|
} else if (isUndefined(obj)) { |
|
65
|
|
|
return 'undefined'; |
|
66
|
|
|
} else if (typeof obj !== 'string') { |
|
67
|
|
|
return serializeObject(obj, maxDepth); |
|
68
|
|
|
} |
|
69
|
|
|
return obj; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/* exported |
|
73
|
|
|
minErrConfig, |
|
74
|
|
|
errorHandlingConfig, |
|
75
|
|
|
isValidObjectMaxDepth |
|
76
|
|
|
*/ |
|
77
|
|
|
|
|
78
|
|
|
var minErrConfig = { |
|
79
|
|
|
objectMaxDepth: 5, |
|
80
|
|
|
urlErrorParamsEnabled: true |
|
81
|
|
|
}; |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* @ngdoc function |
|
85
|
|
|
* @name angular.errorHandlingConfig |
|
86
|
|
|
* @module ng |
|
87
|
|
|
* @kind function |
|
88
|
|
|
* |
|
89
|
|
|
* @description |
|
90
|
|
|
* Configure several aspects of error handling in AngularJS if used as a setter or return the |
|
91
|
|
|
* current configuration if used as a getter. The following options are supported: |
|
92
|
|
|
* |
|
93
|
|
|
* - **objectMaxDepth**: The maximum depth to which objects are traversed when stringified for error messages. |
|
94
|
|
|
* |
|
95
|
|
|
* Omitted or undefined options will leave the corresponding configuration values unchanged. |
|
96
|
|
|
* |
|
97
|
|
|
* @param {Object=} config - The configuration object. May only contain the options that need to be |
|
98
|
|
|
* updated. Supported keys: |
|
99
|
|
|
* |
|
100
|
|
|
* * `objectMaxDepth` **{Number}** - The max depth for stringifying objects. Setting to a |
|
101
|
|
|
* non-positive or non-numeric value, removes the max depth limit. |
|
102
|
|
|
* Default: 5 |
|
103
|
|
|
* |
|
104
|
|
|
* * `urlErrorParamsEnabled` **{Boolean}** - Specifies whether the generated error url will |
|
105
|
|
|
* contain the parameters of the thrown error. Disabling the parameters can be useful if the |
|
106
|
|
|
* generated error url is very long. |
|
107
|
|
|
* |
|
108
|
|
|
* Default: true. When used without argument, it returns the current value. |
|
109
|
|
|
*/ |
|
110
|
|
|
function errorHandlingConfig(config) { |
|
|
|
|
|
|
111
|
|
|
if (isObject(config)) { |
|
112
|
|
|
if (isDefined(config.objectMaxDepth)) { |
|
113
|
|
|
minErrConfig.objectMaxDepth = isValidObjectMaxDepth(config.objectMaxDepth) ? config.objectMaxDepth : NaN; |
|
114
|
|
|
} |
|
115
|
|
|
if (isDefined(config.urlErrorParamsEnabled) && isBoolean(config.urlErrorParamsEnabled)) { |
|
116
|
|
|
minErrConfig.urlErrorParamsEnabled = config.urlErrorParamsEnabled; |
|
|
|
|
|
|
117
|
|
|
} |
|
118
|
|
|
} else { |
|
119
|
|
|
return minErrConfig; |
|
120
|
|
|
} |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
/** |
|
124
|
|
|
* @private |
|
125
|
|
|
* @param {Number} maxDepth |
|
126
|
|
|
* @return {boolean} |
|
127
|
|
|
*/ |
|
128
|
|
|
function isValidObjectMaxDepth(maxDepth) { |
|
129
|
|
|
return isNumber(maxDepth) && maxDepth > 0; |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
|
|
133
|
|
|
/** |
|
134
|
|
|
* @description |
|
135
|
|
|
* |
|
136
|
|
|
* This object provides a utility for producing rich Error messages within |
|
137
|
|
|
* AngularJS. It can be called as follows: |
|
138
|
|
|
* |
|
139
|
|
|
* var exampleMinErr = minErr('example'); |
|
140
|
|
|
* throw exampleMinErr('one', 'This {0} is {1}', foo, bar); |
|
141
|
|
|
* |
|
142
|
|
|
* The above creates an instance of minErr in the example namespace. The |
|
143
|
|
|
* resulting error will have a namespaced error code of example.one. The |
|
144
|
|
|
* resulting error will replace {0} with the value of foo, and {1} with the |
|
145
|
|
|
* value of bar. The object is not restricted in the number of arguments it can |
|
146
|
|
|
* take. |
|
147
|
|
|
* |
|
148
|
|
|
* If fewer arguments are specified than necessary for interpolation, the extra |
|
149
|
|
|
* interpolation markers will be preserved in the final string. |
|
150
|
|
|
* |
|
151
|
|
|
* Since data will be parsed statically during a build step, some restrictions |
|
152
|
|
|
* are applied with respect to how minErr instances are created and called. |
|
153
|
|
|
* Instances should have names of the form namespaceMinErr for a minErr created |
|
154
|
|
|
* using minErr('namespace'). Error codes, namespaces and template strings |
|
155
|
|
|
* should all be static strings, not variables or general expressions. |
|
156
|
|
|
* |
|
157
|
|
|
* @param {string} module The namespace to use for the new minErr instance. |
|
158
|
|
|
* @param {function} ErrorConstructor Custom error constructor to be instantiated when returning |
|
159
|
|
|
* error from returned function, for cases when a particular type of error is useful. |
|
160
|
|
|
* @returns {function(code:string, template:string, ...templateArgs): Error} minErr instance |
|
161
|
|
|
*/ |
|
162
|
|
|
|
|
163
|
|
|
function minErr(module, ErrorConstructor) { |
|
164
|
|
|
ErrorConstructor = ErrorConstructor || Error; |
|
165
|
|
|
|
|
166
|
|
|
var url = 'https://errors.angularjs.org/1.8.3/'; |
|
167
|
|
|
var regex = url.replace('.', '\\.') + '[\\s\\S]*'; |
|
168
|
|
|
var errRegExp = new RegExp(regex, 'g'); |
|
169
|
|
|
|
|
170
|
|
|
return function() { |
|
171
|
|
|
var code = arguments[0], |
|
172
|
|
|
template = arguments[1], |
|
173
|
|
|
message = '[' + (module ? module + ':' : '') + code + '] ', |
|
174
|
|
|
templateArgs = sliceArgs(arguments, 2).map(function(arg) { |
|
175
|
|
|
return toDebugString(arg, minErrConfig.objectMaxDepth); |
|
176
|
|
|
}), |
|
177
|
|
|
paramPrefix, i; |
|
178
|
|
|
|
|
179
|
|
|
// A minErr message has two parts: the message itself and the url that contains the |
|
180
|
|
|
// encoded message. |
|
181
|
|
|
// The message's parameters can contain other error messages which also include error urls. |
|
182
|
|
|
// To prevent the messages from getting too long, we strip the error urls from the parameters. |
|
183
|
|
|
|
|
184
|
|
|
message += template.replace(/\{\d+\}/g, function(match) { |
|
185
|
|
|
var index = +match.slice(1, -1); |
|
186
|
|
|
|
|
187
|
|
|
if (index < templateArgs.length) { |
|
188
|
|
|
return templateArgs[index].replace(errRegExp, ''); |
|
189
|
|
|
} |
|
190
|
|
|
|
|
191
|
|
|
return match; |
|
192
|
|
|
}); |
|
193
|
|
|
|
|
194
|
|
|
message += '\n' + url + (module ? module + '/' : '') + code; |
|
195
|
|
|
|
|
196
|
|
|
if (minErrConfig.urlErrorParamsEnabled) { |
|
197
|
|
|
for (i = 0, paramPrefix = '?'; i < templateArgs.length; i++, paramPrefix = '&') { |
|
198
|
|
|
message += paramPrefix + 'p' + i + '=' + encodeURIComponent(templateArgs[i]); |
|
199
|
|
|
} |
|
200
|
|
|
} |
|
201
|
|
|
|
|
202
|
|
|
return new ErrorConstructor(message); |
|
203
|
|
|
}; |
|
204
|
|
|
} |
|
205
|
|
|
|
|
206
|
|
|
/** |
|
207
|
|
|
* @ngdoc type |
|
208
|
|
|
* @name angular.Module |
|
209
|
|
|
* @module ng |
|
210
|
|
|
* @description |
|
211
|
|
|
* |
|
212
|
|
|
* Interface for configuring AngularJS {@link angular.module modules}. |
|
213
|
|
|
*/ |
|
214
|
|
|
|
|
215
|
|
|
function setupModuleLoader(window) { |
|
216
|
|
|
|
|
217
|
|
|
var $injectorMinErr = minErr('$injector'); |
|
218
|
|
|
var ngMinErr = minErr('ng'); |
|
219
|
|
|
|
|
220
|
|
|
function ensure(obj, name, factory) { |
|
221
|
|
|
return obj[name] || (obj[name] = factory()); |
|
222
|
|
|
} |
|
223
|
|
|
|
|
224
|
|
|
var angular = ensure(window, 'angular', Object); |
|
225
|
|
|
|
|
226
|
|
|
// We need to expose `angular.$$minErr` to modules such as `ngResource` that reference it during bootstrap |
|
227
|
|
|
angular.$$minErr = angular.$$minErr || minErr; |
|
228
|
|
|
|
|
229
|
|
|
return ensure(angular, 'module', function() { |
|
230
|
|
|
/** @type {Object.<string, angular.Module>} */ |
|
231
|
|
|
var modules = {}; |
|
232
|
|
|
|
|
233
|
|
|
/** |
|
234
|
|
|
* @ngdoc function |
|
235
|
|
|
* @name angular.module |
|
236
|
|
|
* @module ng |
|
237
|
|
|
* @description |
|
238
|
|
|
* |
|
239
|
|
|
* The `angular.module` is a global place for creating, registering and retrieving AngularJS |
|
240
|
|
|
* modules. |
|
241
|
|
|
* All modules (AngularJS core or 3rd party) that should be available to an application must be |
|
242
|
|
|
* registered using this mechanism. |
|
243
|
|
|
* |
|
244
|
|
|
* Passing one argument retrieves an existing {@link angular.Module}, |
|
245
|
|
|
* whereas passing more than one argument creates a new {@link angular.Module} |
|
246
|
|
|
* |
|
247
|
|
|
* |
|
248
|
|
|
* # Module |
|
249
|
|
|
* |
|
250
|
|
|
* A module is a collection of services, directives, controllers, filters, and configuration information. |
|
251
|
|
|
* `angular.module` is used to configure the {@link auto.$injector $injector}. |
|
252
|
|
|
* |
|
253
|
|
|
* ```js |
|
254
|
|
|
* // Create a new module |
|
255
|
|
|
* var myModule = angular.module('myModule', []); |
|
256
|
|
|
* |
|
257
|
|
|
* // register a new service |
|
258
|
|
|
* myModule.value('appName', 'MyCoolApp'); |
|
259
|
|
|
* |
|
260
|
|
|
* // configure existing services inside initialization blocks. |
|
261
|
|
|
* myModule.config(['$locationProvider', function($locationProvider) { |
|
262
|
|
|
* // Configure existing providers |
|
263
|
|
|
* $locationProvider.hashPrefix('!'); |
|
264
|
|
|
* }]); |
|
265
|
|
|
* ``` |
|
266
|
|
|
* |
|
267
|
|
|
* Then you can create an injector and load your modules like this: |
|
268
|
|
|
* |
|
269
|
|
|
* ```js |
|
270
|
|
|
* var injector = angular.injector(['ng', 'myModule']) |
|
271
|
|
|
* ``` |
|
272
|
|
|
* |
|
273
|
|
|
* However it's more likely that you'll just use |
|
274
|
|
|
* {@link ng.directive:ngApp ngApp} or |
|
275
|
|
|
* {@link angular.bootstrap} to simplify this process for you. |
|
276
|
|
|
* |
|
277
|
|
|
* @param {!string} name The name of the module to create or retrieve. |
|
278
|
|
|
* @param {!Array.<string>=} requires If specified then new module is being created. If |
|
279
|
|
|
* unspecified then the module is being retrieved for further configuration. |
|
280
|
|
|
* @param {Function=} configFn Optional configuration function for the module. Same as |
|
281
|
|
|
* {@link angular.Module#config Module#config()}. |
|
282
|
|
|
* @returns {angular.Module} new module with the {@link angular.Module} api. |
|
283
|
|
|
*/ |
|
284
|
|
|
return function module(name, requires, configFn) { |
|
285
|
|
|
|
|
286
|
|
|
var info = {}; |
|
287
|
|
|
|
|
288
|
|
|
var assertNotHasOwnProperty = function(name, context) { |
|
289
|
|
|
if (name === 'hasOwnProperty') { |
|
290
|
|
|
throw ngMinErr('badname', 'hasOwnProperty is not a valid {0} name', context); |
|
291
|
|
|
} |
|
292
|
|
|
}; |
|
293
|
|
|
|
|
294
|
|
|
assertNotHasOwnProperty(name, 'module'); |
|
295
|
|
|
if (requires && modules.hasOwnProperty(name)) { |
|
296
|
|
|
modules[name] = null; |
|
297
|
|
|
} |
|
298
|
|
|
return ensure(modules, name, function() { |
|
299
|
|
|
if (!requires) { |
|
300
|
|
|
throw $injectorMinErr('nomod', 'Module \'{0}\' is not available! You either misspelled ' + |
|
301
|
|
|
'the module name or forgot to load it. If registering a module ensure that you ' + |
|
302
|
|
|
'specify the dependencies as the second argument.', name); |
|
303
|
|
|
} |
|
304
|
|
|
|
|
305
|
|
|
/** @type {!Array.<Array.<*>>} */ |
|
306
|
|
|
var invokeQueue = []; |
|
307
|
|
|
|
|
308
|
|
|
/** @type {!Array.<Function>} */ |
|
309
|
|
|
var configBlocks = []; |
|
310
|
|
|
|
|
311
|
|
|
/** @type {!Array.<Function>} */ |
|
312
|
|
|
var runBlocks = []; |
|
313
|
|
|
|
|
314
|
|
|
var config = invokeLater('$injector', 'invoke', 'push', configBlocks); |
|
315
|
|
|
|
|
316
|
|
|
/** @type {angular.Module} */ |
|
317
|
|
|
var moduleInstance = { |
|
318
|
|
|
// Private state |
|
319
|
|
|
_invokeQueue: invokeQueue, |
|
320
|
|
|
_configBlocks: configBlocks, |
|
321
|
|
|
_runBlocks: runBlocks, |
|
322
|
|
|
|
|
323
|
|
|
/** |
|
324
|
|
|
* @ngdoc method |
|
325
|
|
|
* @name angular.Module#info |
|
326
|
|
|
* @module ng |
|
327
|
|
|
* |
|
328
|
|
|
* @param {Object=} info Information about the module |
|
329
|
|
|
* @returns {Object|Module} The current info object for this module if called as a getter, |
|
330
|
|
|
* or `this` if called as a setter. |
|
331
|
|
|
* |
|
332
|
|
|
* @description |
|
333
|
|
|
* Read and write custom information about this module. |
|
334
|
|
|
* For example you could put the version of the module in here. |
|
335
|
|
|
* |
|
336
|
|
|
* ```js |
|
337
|
|
|
* angular.module('myModule', []).info({ version: '1.0.0' }); |
|
338
|
|
|
* ``` |
|
339
|
|
|
* |
|
340
|
|
|
* The version could then be read back out by accessing the module elsewhere: |
|
341
|
|
|
* |
|
342
|
|
|
* ``` |
|
343
|
|
|
* var version = angular.module('myModule').info().version; |
|
344
|
|
|
* ``` |
|
345
|
|
|
* |
|
346
|
|
|
* You can also retrieve this information during runtime via the |
|
347
|
|
|
* {@link $injector#modules `$injector.modules`} property: |
|
348
|
|
|
* |
|
349
|
|
|
* ```js |
|
350
|
|
|
* var version = $injector.modules['myModule'].info().version; |
|
351
|
|
|
* ``` |
|
352
|
|
|
*/ |
|
353
|
|
|
info: function(value) { |
|
354
|
|
|
if (isDefined(value)) { |
|
355
|
|
|
if (!isObject(value)) throw ngMinErr('aobj', 'Argument \'{0}\' must be an object', 'value'); |
|
356
|
|
|
info = value; |
|
357
|
|
|
return this; |
|
358
|
|
|
} |
|
359
|
|
|
return info; |
|
360
|
|
|
}, |
|
361
|
|
|
|
|
362
|
|
|
/** |
|
363
|
|
|
* @ngdoc property |
|
364
|
|
|
* @name angular.Module#requires |
|
365
|
|
|
* @module ng |
|
366
|
|
|
* |
|
367
|
|
|
* @description |
|
368
|
|
|
* Holds the list of modules which the injector will load before the current module is |
|
369
|
|
|
* loaded. |
|
370
|
|
|
*/ |
|
371
|
|
|
requires: requires, |
|
372
|
|
|
|
|
373
|
|
|
/** |
|
374
|
|
|
* @ngdoc property |
|
375
|
|
|
* @name angular.Module#name |
|
376
|
|
|
* @module ng |
|
377
|
|
|
* |
|
378
|
|
|
* @description |
|
379
|
|
|
* Name of the module. |
|
380
|
|
|
*/ |
|
381
|
|
|
name: name, |
|
382
|
|
|
|
|
383
|
|
|
|
|
384
|
|
|
/** |
|
385
|
|
|
* @ngdoc method |
|
386
|
|
|
* @name angular.Module#provider |
|
387
|
|
|
* @module ng |
|
388
|
|
|
* @param {string} name service name |
|
389
|
|
|
* @param {Function} providerType Construction function for creating new instance of the |
|
390
|
|
|
* service. |
|
391
|
|
|
* @description |
|
392
|
|
|
* See {@link auto.$provide#provider $provide.provider()}. |
|
393
|
|
|
*/ |
|
394
|
|
|
provider: invokeLaterAndSetModuleName('$provide', 'provider'), |
|
395
|
|
|
|
|
396
|
|
|
/** |
|
397
|
|
|
* @ngdoc method |
|
398
|
|
|
* @name angular.Module#factory |
|
399
|
|
|
* @module ng |
|
400
|
|
|
* @param {string} name service name |
|
401
|
|
|
* @param {Function} providerFunction Function for creating new instance of the service. |
|
402
|
|
|
* @description |
|
403
|
|
|
* See {@link auto.$provide#factory $provide.factory()}. |
|
404
|
|
|
*/ |
|
405
|
|
|
factory: invokeLaterAndSetModuleName('$provide', 'factory'), |
|
406
|
|
|
|
|
407
|
|
|
/** |
|
408
|
|
|
* @ngdoc method |
|
409
|
|
|
* @name angular.Module#service |
|
410
|
|
|
* @module ng |
|
411
|
|
|
* @param {string} name service name |
|
412
|
|
|
* @param {Function} constructor A constructor function that will be instantiated. |
|
413
|
|
|
* @description |
|
414
|
|
|
* See {@link auto.$provide#service $provide.service()}. |
|
415
|
|
|
*/ |
|
416
|
|
|
service: invokeLaterAndSetModuleName('$provide', 'service'), |
|
417
|
|
|
|
|
418
|
|
|
/** |
|
419
|
|
|
* @ngdoc method |
|
420
|
|
|
* @name angular.Module#value |
|
421
|
|
|
* @module ng |
|
422
|
|
|
* @param {string} name service name |
|
423
|
|
|
* @param {*} object Service instance object. |
|
424
|
|
|
* @description |
|
425
|
|
|
* See {@link auto.$provide#value $provide.value()}. |
|
426
|
|
|
*/ |
|
427
|
|
|
value: invokeLater('$provide', 'value'), |
|
428
|
|
|
|
|
429
|
|
|
/** |
|
430
|
|
|
* @ngdoc method |
|
431
|
|
|
* @name angular.Module#constant |
|
432
|
|
|
* @module ng |
|
433
|
|
|
* @param {string} name constant name |
|
434
|
|
|
* @param {*} object Constant value. |
|
435
|
|
|
* @description |
|
436
|
|
|
* Because the constants are fixed, they get applied before other provide methods. |
|
437
|
|
|
* See {@link auto.$provide#constant $provide.constant()}. |
|
438
|
|
|
*/ |
|
439
|
|
|
constant: invokeLater('$provide', 'constant', 'unshift'), |
|
440
|
|
|
|
|
441
|
|
|
/** |
|
442
|
|
|
* @ngdoc method |
|
443
|
|
|
* @name angular.Module#decorator |
|
444
|
|
|
* @module ng |
|
445
|
|
|
* @param {string} name The name of the service to decorate. |
|
446
|
|
|
* @param {Function} decorFn This function will be invoked when the service needs to be |
|
447
|
|
|
* instantiated and should return the decorated service instance. |
|
448
|
|
|
* @description |
|
449
|
|
|
* See {@link auto.$provide#decorator $provide.decorator()}. |
|
450
|
|
|
*/ |
|
451
|
|
|
decorator: invokeLaterAndSetModuleName('$provide', 'decorator', configBlocks), |
|
452
|
|
|
|
|
453
|
|
|
/** |
|
454
|
|
|
* @ngdoc method |
|
455
|
|
|
* @name angular.Module#animation |
|
456
|
|
|
* @module ng |
|
457
|
|
|
* @param {string} name animation name |
|
458
|
|
|
* @param {Function} animationFactory Factory function for creating new instance of an |
|
459
|
|
|
* animation. |
|
460
|
|
|
* @description |
|
461
|
|
|
* |
|
462
|
|
|
* **NOTE**: animations take effect only if the **ngAnimate** module is loaded. |
|
463
|
|
|
* |
|
464
|
|
|
* |
|
465
|
|
|
* Defines an animation hook that can be later used with |
|
466
|
|
|
* {@link $animate $animate} service and directives that use this service. |
|
467
|
|
|
* |
|
468
|
|
|
* ```js |
|
469
|
|
|
* module.animation('.animation-name', function($inject1, $inject2) { |
|
470
|
|
|
* return { |
|
471
|
|
|
* eventName : function(element, done) { |
|
472
|
|
|
* //code to run the animation |
|
473
|
|
|
* //once complete, then run done() |
|
474
|
|
|
* return function cancellationFunction(element) { |
|
475
|
|
|
* //code to cancel the animation |
|
476
|
|
|
* } |
|
477
|
|
|
* } |
|
478
|
|
|
* } |
|
479
|
|
|
* }) |
|
480
|
|
|
* ``` |
|
481
|
|
|
* |
|
482
|
|
|
* See {@link ng.$animateProvider#register $animateProvider.register()} and |
|
483
|
|
|
* {@link ngAnimate ngAnimate module} for more information. |
|
484
|
|
|
*/ |
|
485
|
|
|
animation: invokeLaterAndSetModuleName('$animateProvider', 'register'), |
|
486
|
|
|
|
|
487
|
|
|
/** |
|
488
|
|
|
* @ngdoc method |
|
489
|
|
|
* @name angular.Module#filter |
|
490
|
|
|
* @module ng |
|
491
|
|
|
* @param {string} name Filter name - this must be a valid AngularJS expression identifier |
|
492
|
|
|
* @param {Function} filterFactory Factory function for creating new instance of filter. |
|
493
|
|
|
* @description |
|
494
|
|
|
* See {@link ng.$filterProvider#register $filterProvider.register()}. |
|
495
|
|
|
* |
|
496
|
|
|
* <div class="alert alert-warning"> |
|
497
|
|
|
* **Note:** Filter names must be valid AngularJS {@link expression} identifiers, such as `uppercase` or `orderBy`. |
|
498
|
|
|
* Names with special characters, such as hyphens and dots, are not allowed. If you wish to namespace |
|
499
|
|
|
* your filters, then you can use capitalization (`myappSubsectionFilterx`) or underscores |
|
500
|
|
|
* (`myapp_subsection_filterx`). |
|
501
|
|
|
* </div> |
|
502
|
|
|
*/ |
|
503
|
|
|
filter: invokeLaterAndSetModuleName('$filterProvider', 'register'), |
|
504
|
|
|
|
|
505
|
|
|
/** |
|
506
|
|
|
* @ngdoc method |
|
507
|
|
|
* @name angular.Module#controller |
|
508
|
|
|
* @module ng |
|
509
|
|
|
* @param {string|Object} name Controller name, or an object map of controllers where the |
|
510
|
|
|
* keys are the names and the values are the constructors. |
|
511
|
|
|
* @param {Function} constructor Controller constructor function. |
|
512
|
|
|
* @description |
|
513
|
|
|
* See {@link ng.$controllerProvider#register $controllerProvider.register()}. |
|
514
|
|
|
*/ |
|
515
|
|
|
controller: invokeLaterAndSetModuleName('$controllerProvider', 'register'), |
|
516
|
|
|
|
|
517
|
|
|
/** |
|
518
|
|
|
* @ngdoc method |
|
519
|
|
|
* @name angular.Module#directive |
|
520
|
|
|
* @module ng |
|
521
|
|
|
* @param {string|Object} name Directive name, or an object map of directives where the |
|
522
|
|
|
* keys are the names and the values are the factories. |
|
523
|
|
|
* @param {Function} directiveFactory Factory function for creating new instance of |
|
524
|
|
|
* directives. |
|
525
|
|
|
* @description |
|
526
|
|
|
* See {@link ng.$compileProvider#directive $compileProvider.directive()}. |
|
527
|
|
|
*/ |
|
528
|
|
|
directive: invokeLaterAndSetModuleName('$compileProvider', 'directive'), |
|
529
|
|
|
|
|
530
|
|
|
/** |
|
531
|
|
|
* @ngdoc method |
|
532
|
|
|
* @name angular.Module#component |
|
533
|
|
|
* @module ng |
|
534
|
|
|
* @param {string|Object} name Name of the component in camelCase (i.e. `myComp` which will match `<my-comp>`), |
|
535
|
|
|
* or an object map of components where the keys are the names and the values are the component definition objects. |
|
536
|
|
|
* @param {Object} options Component definition object (a simplified |
|
537
|
|
|
* {@link ng.$compile#directive-definition-object directive definition object}) |
|
538
|
|
|
* |
|
539
|
|
|
* @description |
|
540
|
|
|
* See {@link ng.$compileProvider#component $compileProvider.component()}. |
|
541
|
|
|
*/ |
|
542
|
|
|
component: invokeLaterAndSetModuleName('$compileProvider', 'component'), |
|
543
|
|
|
|
|
544
|
|
|
/** |
|
545
|
|
|
* @ngdoc method |
|
546
|
|
|
* @name angular.Module#config |
|
547
|
|
|
* @module ng |
|
548
|
|
|
* @param {Function} configFn Execute this function on module load. Useful for service |
|
549
|
|
|
* configuration. |
|
550
|
|
|
* @description |
|
551
|
|
|
* Use this method to configure services by injecting their |
|
552
|
|
|
* {@link angular.Module#provider `providers`}, e.g. for adding routes to the |
|
553
|
|
|
* {@link ngRoute.$routeProvider $routeProvider}. |
|
554
|
|
|
* |
|
555
|
|
|
* Note that you can only inject {@link angular.Module#provider `providers`} and |
|
556
|
|
|
* {@link angular.Module#constant `constants`} into this function. |
|
557
|
|
|
* |
|
558
|
|
|
* For more about how to configure services, see |
|
559
|
|
|
* {@link providers#provider-recipe Provider Recipe}. |
|
560
|
|
|
*/ |
|
561
|
|
|
config: config, |
|
562
|
|
|
|
|
563
|
|
|
/** |
|
564
|
|
|
* @ngdoc method |
|
565
|
|
|
* @name angular.Module#run |
|
566
|
|
|
* @module ng |
|
567
|
|
|
* @param {Function} initializationFn Execute this function after injector creation. |
|
568
|
|
|
* Useful for application initialization. |
|
569
|
|
|
* @description |
|
570
|
|
|
* Use this method to register work which should be performed when the injector is done |
|
571
|
|
|
* loading all modules. |
|
572
|
|
|
*/ |
|
573
|
|
|
run: function(block) { |
|
574
|
|
|
runBlocks.push(block); |
|
575
|
|
|
return this; |
|
576
|
|
|
} |
|
577
|
|
|
}; |
|
578
|
|
|
|
|
579
|
|
|
if (configFn) { |
|
580
|
|
|
config(configFn); |
|
581
|
|
|
} |
|
582
|
|
|
|
|
583
|
|
|
return moduleInstance; |
|
584
|
|
|
|
|
585
|
|
|
/** |
|
586
|
|
|
* @param {string} provider |
|
587
|
|
|
* @param {string} method |
|
588
|
|
|
* @param {String=} insertMethod |
|
589
|
|
|
* @returns {angular.Module} |
|
590
|
|
|
*/ |
|
591
|
|
|
function invokeLater(provider, method, insertMethod, queue) { |
|
592
|
|
|
if (!queue) queue = invokeQueue; |
|
593
|
|
|
return function() { |
|
594
|
|
|
queue[insertMethod || 'push']([provider, method, arguments]); |
|
595
|
|
|
return moduleInstance; |
|
596
|
|
|
}; |
|
597
|
|
|
} |
|
598
|
|
|
|
|
599
|
|
|
/** |
|
600
|
|
|
* @param {string} provider |
|
601
|
|
|
* @param {string} method |
|
602
|
|
|
* @returns {angular.Module} |
|
603
|
|
|
*/ |
|
604
|
|
|
function invokeLaterAndSetModuleName(provider, method, queue) { |
|
605
|
|
|
if (!queue) queue = invokeQueue; |
|
606
|
|
|
return function(recipeName, factoryFunction) { |
|
607
|
|
|
if (factoryFunction && isFunction(factoryFunction)) factoryFunction.$$moduleName = name; |
|
608
|
|
|
queue.push([provider, method, arguments]); |
|
609
|
|
|
return moduleInstance; |
|
610
|
|
|
}; |
|
611
|
|
|
} |
|
612
|
|
|
}); |
|
613
|
|
|
}; |
|
614
|
|
|
}); |
|
615
|
|
|
|
|
616
|
|
|
} |
|
617
|
|
|
|
|
618
|
|
|
setupModuleLoader(window); |
|
619
|
|
|
})(window); |
|
620
|
|
|
|
|
621
|
|
|
/** |
|
622
|
|
|
* Closure compiler type information |
|
623
|
|
|
* |
|
624
|
|
|
* @typedef { { |
|
625
|
|
|
* requires: !Array.<string>, |
|
626
|
|
|
* invokeQueue: !Array.<Array.<*>>, |
|
627
|
|
|
* |
|
628
|
|
|
* service: function(string, Function):angular.Module, |
|
629
|
|
|
* factory: function(string, Function):angular.Module, |
|
630
|
|
|
* value: function(string, *):angular.Module, |
|
631
|
|
|
* |
|
632
|
|
|
* filter: function(string, Function):angular.Module, |
|
633
|
|
|
* |
|
634
|
|
|
* init: function(Function):angular.Module |
|
635
|
|
|
* } } |
|
636
|
|
|
*/ |
|
637
|
|
|
angular.Module; |
|
|
|
|
|
|
638
|
|
|
|
|
639
|
|
|
|